<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询词本</title>
    <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/dashboard.css">
</head>

<body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/user/home/">单词助手</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    {% if request.user.is_authenticated %}
                    <li><a href="/user/mydetail/">{{ request.user.username }}</a></li>
                    <li><a href="/user/logout/">注销</a></li>
                    {% else %}
                    <li><a href="/user/login/">登录</a></li>
                    <li><a href="/user/register/">注册</a></li>
                    {% endif %}


                </ul>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-3 col-md-2 sidebar">
                <ul class="nav nav-sidebar">
                    <li><a href="/user/home/">首页</a></li>
                    <li><a href="/user/mydetail/">个人资料</a></li>
                    <li class="active"><a href="/user/mybook/">个人词本</a></li>
                </ul>
            </div>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
               <form action="" method="POST">
                {% csrf_token %}<br>
                请输入您要查询的单词本的名称：<input type="text" name="search_book"><br><br>
                <button class="btn btn-primary" type="submit">提交</button>
                <button class="btn btn-primary" type="reset">重置</button>
               </form>
               {% if flag == True %}
               <br><br><br>
               <table class="table">
                <thead>
                    <th>单词本id</th>
                    <th>单词本名称</th>
                    <th>创建时间</th>
                    <th>创建用户</th>
                    <th>是否公开</th>
                    <th>是否需要密码</th>
                    <th>操作</th>
                </thead>
                <tbody>
                    {% for search_book in search_book_list %}
                    <tr>
                        <td>{{ search_book.pk }}</td>
                        <td>{{ search_book.title }}</td>
                        <td>{{ search_book.pub_date }}</td>
                        <td>{{ search_book.master }}</td>
                        <td>{{ search_book.is_public }}</td>
                        <td>{{ search_book.need_pwd }}</td>
                        {% if search_book.need_pwd %}
                        <td><a class="btn btn-primary" href="/user/verifypwd/?pk={{ search_book.pk }}">收藏</a></td>
                        {% else %}
                        <td><a class="btn btn-primary" href="/user/collect_mybook/?pk={{ search_book.pk }}">收藏</a></td>
                        {% endif %}
                    </tr>
                    {% empty %}
                    <p><strong>未搜索到相关词本，请更换搜索词再次尝试</strong></p>
                    {% endfor %}
                </tbody>
               </table>
               {% endif %}
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


</body>

</html>